<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>第二种头部</title>
    <link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui.css" />
    <style>
        html,
        body {
            width: 100%;
            min-height: 100%;
            background: #f7f7f7;
            line-height: 1;
        }
        /*修改icon*/

        .left_icon {
            font-size: 1rem!important;
            color: #000!important;
        }

        .right_img {
            width: 1rem;
        }
        /*修改头部标题*/

        .header_title {
            font-size: 0.9rem;
            font-weight: bold;
        }
        /*固定头部*/

        .header {
            background-color: #fff;
            border: none!important;
            z-index: 8!important;
        }
        /*遮罩*/

        .cover {
            position: fixed;
            margin-top: 25px;
            min-height: 2.25rem;
            width: 100vw;
            background-color: rgba(0, 0, 0, .3);
            top: 0;
            z-index: 20;
            display: none;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav header" id='header' style="padding-top:25px;">
        <a class="aui-pull-left aui-btn" onclick="close_win()">
            <span class="aui-iconfont aui-icon-left left_icon"></span>
        </a>
        <div class="aui-title header_title">第二种头部</div>
        <a class="aui-pull-right aui-btn">
            <img src="" alt="" class="right_img">
        </a>
    </header>
    <div class="cover"></div>
</body>
<script type="text/javascript" src="../../../script/api.js"></script>
<script type="text/javascript" src="../../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../../script/vue.min.js"></script>
<script type="text/javascript" src="../../../script/utils.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script type="text/javascript" src="../../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../../script/aui-pull-refresh.js"></script>
<script type="text/javascript">
    apiready = function() {

        //获取header的高度
        var oHeader = $api.byId("header");
        var headerH = $api.offset(oHeader).h;

        //打开对应的frm
        if (api.pageParam.type == "好友") {
            $('.header_title').html(api.pageParam.title);
            $('.right_img').prop('src', '' + api.pageParam.img_src);
            api.openFrame({
                name: 'friend_detail',
                url: '../friend_detail.html',
                rect: {
                    x: 0,
                    y: headerH,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam: {
                    friend_id: api.pageParam.friend_id
                },
                bounces: true,
                bgColor: 'rgba(0,0,0,0)',
                vScrollBarEnabled: true,
                hScrollBarEnabled: true
            });
        } else if (api.pageParam.type == "等待好友") {
            $('.header_title').html(api.pageParam.title);
            $('.right_img').prop('src', '' + api.pageParam.img_src);
            api.openFrame({
                name: 'waiting_friend',
                url: '../waiting_friend.html',
                rect: {
                    x: 0,
                    y: headerH,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam: {
                    name: 'test'
                },
                bounces: true,
                bgColor: 'rgba(0,0,0,0)',
                vScrollBarEnabled: true,
                hScrollBarEnabled: true
            });
        } else if (api.pageParam.type == "单聊资料") {
            $('.header_title').html(api.pageParam.title);
            $('.right_img').prop('src', '' + api.pageParam.img_src);
            api.openFrame({
                name: 'friend_detail_set',
                url: '../friend_detail_set.html',
                rect: {
                    x: 0,
                    y: headerH,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam: {
                    target_id:api.pageParam.target_id
                },
                bounces: true,
                bgColor: 'rgba(0,0,0,0)',
                vScrollBarEnabled: true,
                hScrollBarEnabled: true
            });
        }


    };

    // 关闭当前窗口
    function close_win() {
        api.closeWin({});
    }


    //点击遮罩关闭遮罩
    function close_cover() {
        $('.cover').hide();
    }


    // 头部右侧按钮点击事件

    $('body').on('click', '.aui-pull-right', function() {
        var img_src = $('.right_img').attr('src');
        // 判断右上角图片是什么
        if (img_src.indexOf('delete_friend') != -1) {
            $('.cover').show();
            if (api.pageParam.type == "好友") {
                api.execScript({
                    frameName: 'friend_detail',
                    script: 'open_diglog();'
                });
            } else {
                api.execScript({
                    frameName: 'friend_detail_set',
                    script: 'open_diglog();'
                });
            }
        } else if (img_src.indexOf('add_friend') != -1) {
            api.openWin({
                name: 'four_one_header',
                url: 'four_one_header.html',
                pageParam: {
                    title: '添加新的朋友',
                    type: "",
                    img_src: ""
                }
            });

        }
    })


    function test(){
      alert(11111)
    }
</script>

</html>
